<?php
/*
 * Limb PHP Framework
 *
 * @link http://limb-project.com
 * @copyright  Copyright &copy; 2004-2009 BIT(http://bit-creative.com)
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */
lmb_require('limb/log/src/writers/lmbLogBaseWriter.class.php');

class lmbBaseWriterTest extends UnitTestCase {

  function testWrite()
  {
    $writer = new lmbLogBaseWritterForTest(new lmbUri());
    $result = $writer->write(new lmbLogEntry(LOG_ERR, 'foo'));
    $this->assertTrue($result instanceof lmbLogEntry);
  }

  function testSetErrorLevel()
  {
    $writer = new lmbLogBaseWritterForTest(new lmbUri());
    $writer->setErrorLevel(LOG_WARNING);

    $result = $writer->write(new lmbLogEntry(LOG_NOTICE, 'notice'));
    $this->assertFalse($result instanceof lmbLogEntry);

    $result = $writer->write(new lmbLogEntry(LOG_INFO, 'info'));
    $this->assertFalse($result instanceof lmbLogEntry);
  }

  function testSetErrorLevelByDSN()
  {
    $writer = new lmbLogBaseWritterForTest(new lmbUri('file://void?level='.LOG_WARNING));

    $result = $writer->write(new lmbLogEntry(LOG_NOTICE, 'notice'));
    $this->assertFalse($result instanceof lmbLogEntry);

    $result = $writer->write(new lmbLogEntry(LOG_INFO, 'info'));
    $this->assertFalse($result instanceof lmbLogEntry);
  }
}

class lmbLogBaseWritterForTest extends lmbLogBaseWriter {}